using HKB.Common;
using HKB.Data.Dal;
using HKB.Data.Dal.S_ClassTableAdapters;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI.WebControls;
namespace HKB.Web
{
	public class Shop_Class
	{
		private Conn conn = null;
		private static Shop_Class _instance = null;
		private static readonly HLShop_ClassTableAdapter Adapter = new HLShop_ClassTableAdapter();
		private string m_UpdateSql = "";
		public static Shop_Class instance
		{
			get
			{
				if (Shop_Class._instance == null)
				{
					Shop_Class._instance = new Shop_Class(new Conn());
				}
				return Shop_Class._instance;
			}
		}
		public Shop_Class()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public Shop_Class(Conn _conn)
		{
			this.conn = _conn;
		}
		public DataTable GetAllClass()
		{
			return Shop_Class.Adapter.GetAllClass();
		}
		public DataTable GetClassByClassID(int ClassID)
		{
			return this.conn.GetDataTable("SELECT * FROM HLShop_Class Where  ClassID=" + ClassID);
		}
		public DataTable GetAllClassNameFillDropDown()
		{
			return this.conn.GetDataTable("SELECT ClassID, ClassName FROM HLShop_Class ORDER BY RootID,OrderByID,Depth asc");
		}
		public DataTable GetAllParentClass(int classid)
		{
			string text = (string)this.conn.GetScalar("Select ParentPath From [HLShop_Class] Where ClassID=" + classid, new IDbDataParameter[0]);
			DataTable dataTable;
			if (text != string.Empty && text != null)
			{
				dataTable = this.conn.GetDataTable(string.Concat(new object[]
				{
					"Select ClassID, ClassName From [HLShop_Class] Where ClassID in(",
					classid,
					",",
					text,
					") Order By RootID"
				}));
			}
			else
			{
				dataTable = this.conn.GetDataTable("Select ClassID, ClassName From [HLShop_Class] Where ClassID=" + classid);
			}
			return dataTable;
		}
		public DataTable GetRootClass()
		{
			return this.conn.GetDataTable("Select * From [HLShop_Class] Where ParentID=0");
		}
		public DataTable GetChildClassByParnetID(int ParentID)
		{
			DataTable result;
			if (ParentID >= 0)
			{
				result = this.conn.GetDataTable("Select * From [HLShop_Class] Where ParentID=" + ParentID);
			}
			else
			{
				result = null;
			}
			return result;
		}
		public DataTable GetClassListByParnetID(int count, int ParentID, params bool[] isalltype)
		{
			DataTable result;
			if (ParentID >= 0)
			{
				if (isalltype.Length == 1 && isalltype[0])
				{
					result = this.conn.GetDataTable(string.Format("Select TOP {0} ClassID,ClassName From [HLShop_Class] Where ParentID={1}  ", count, ParentID));
				}
				else
				{
					result = this.conn.GetDataTable(string.Format("Select TOP {0} ClassID,ClassName From [HLShop_Class] Where ParentID={1} and ShowOnTop=1 ", count, ParentID));
				}
			}
			else
			{
				result = null;
			}
			return result;
		}
		public DataTable GetClassListByParnetID(int count, int notneedcount, int ParentID, params bool[] isalltype)
		{
			string arg;
			if (isalltype.Length == 1 && isalltype[0])
			{
				arg = string.Format(" ParentID={0} ", ParentID);
			}
			else
			{
				arg = string.Format(" ParentID={0} and ShowOnTop=1 ", ParentID);
			}
			DataTable result;
			if (ParentID >= 0)
			{
				result = this.conn.GetDataTable(string.Format("Select TOP {0} ClassID,ClassName From [HLShop_Class] Where {2} AND ClassID not in (select TOP {1} ClassID from [HLShop_Class] where {2}) ", count, notneedcount, arg));
			}
			else
			{
				result = null;
			}
			return result;
		}
		public DataTable GetAllChildClassByParnetID(int ParentID)
		{
			DataTable result;
			if (ParentID > 0)
			{
				string str = (string)this.conn.GetScalar("Select arrChildID [HLShop_Class] Where ClassID=" + ParentID, new IDbDataParameter[0]);
				result = this.conn.GetDataTable("Select * [HLShop_Class] Where ClassID in(" + str + ")");
			}
			else
			{
				result = this.GetRootClass();
			}
			return result;
		}
		public bool UpdateItemCountByClassIDType(int ClassID, string Type)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				this.conn.CreateParameter("@ClassID", SqlDbType.Int, ClassID),
				this.conn.CreateParameter("@Type", SqlDbType.NVarChar, Type)
			};
			int num = this.conn.Execute("Pr_UpdateItemCountByProductClassID", parameters);
			return num > 0;
		}
		public DataTable GetCategoryListByParentID(int ParentID)
		{
			DataTable result;
			if (ParentID != -1)
			{
				result = Shop_Class.Adapter.GetChildClassByParentID(new int?(ParentID));
			}
			else
			{
				result = null;
			}
			return result;
		}
		public int GetMinClassIDByName(string className)
		{
			return this.conn.GetScalar("select min(ClassID) from [HLShop_Class] where ClassName=@ClassName and ParentID=0", new IDbDataParameter[]
			{
				new SqlParameter("ClassName", className)
			}).IsNull(new object[0]).ToInt32(new int[0]);
		}
		public DataTable GetClassByRootID(int RootID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@RootID", DbType.Int32, RootID);
			return this.conn.GetDataTable("SELECT * FROM HLShop_Class where (RootID = @RootID) ORDER BY OrderByID,Depth,ClassID asc", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public int CountProductNumByClassID(int ClassID)
		{
			return this.conn.ExecuteCount("Select count(*) From [HLShop_Product] Where IsApprove=1 AND ClassID=" + ClassID);
		}
		public int CountClassNumByClassID(int ClassID)
		{
			return this.conn.ExecuteCount("Select count(*) From [HLShop_Class] Where ParentID=" + ClassID);
		}
		public DataTable GetAllClassCount()
		{
			DataTable dataTable = new DataTable();
			DataColumn dataColumn = new DataColumn();
			dataColumn.ColumnName = "classname";
			DataColumn dataColumn2 = new DataColumn();
			dataColumn2.ColumnName = "classID";
			DataColumn dataColumn3 = new DataColumn();
			dataColumn3.ColumnName = "ProductCount";
			DataColumn dataColumn4 = new DataColumn();
			dataColumn4.ColumnName = "ClassCount";
			dataTable.Columns.Add(dataColumn2);
			dataTable.Columns.Add(dataColumn);
			dataTable.Columns.Add(dataColumn3);
			dataTable.Columns.Add(dataColumn4);
			DataTable allClass = Shop_Class.Adapter.GetAllClass();
			for (int i = 0; i < allClass.Rows.Count; i++)
			{
				DataRow dataRow = dataTable.NewRow();
				dataRow["classid"] = allClass.Rows[i]["classid"].ToString();
				dataRow["classname"] = allClass.Rows[i]["classname"].ToString();
				dataRow["productcount"] = allClass.Rows[i]["itemCount"].ToString();
				dataRow["ClassCount"] = allClass.Rows[i]["Child"].ToString();
				dataTable.Rows.Add(dataRow);
			}
			return dataTable;
		}
		public void GetChilenClass(int ClassID, ref DataTable dtClass, DataTable dtAllClass)
		{
			DataRow[] array = dtAllClass.Select("ParentID=" + ClassID);
			DataRow[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				DataRow dataRow = array2[i];
				DataRow dataRow2 = dtClass.NewRow();
				dataRow2[0] = dataRow["ClassID"].ToString();
				dtClass.Rows.Add(dataRow2);
				this.GetChilenClass(int.Parse(dataRow["ClassID"].ToString()), ref dtClass, dtAllClass);
			}
		}
		public string GetChilenClass(int ClassID)
		{
			string text = ClassID.ToString() + ",";
			DataTable dataTable = new DataTable();
			DataColumn dataColumn = new DataColumn();
			dataColumn.ColumnName = "classname";
			DataColumn dataColumn2 = new DataColumn();
			dataColumn2.ColumnName = "classID";
			dataTable.Columns.Add(dataColumn2);
			dataTable.Columns.Add(dataColumn);
			DataTable allClass = Shop_Class.Adapter.GetAllClass();
			this.GetChilenClass(ClassID, ref dataTable, allClass);
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				text = text + dataTable.Rows[i]["classID"].ToString() + ",";
			}
			if (text.Length > 1)
			{
				text = text.Remove(text.Length - 1);
			}
			return text;
		}
		public DataTable GetClassMapPathByParentID(int ParentID)
		{
			return Shop_Class.Adapter.GetClassMapPathByParentID(new int?(ParentID));
		}
		public DataTable GetClassBySpecialID(int SpecialID)
		{
			return Shop_Class.Adapter.GetClassBySpecialID(new int?(SpecialID));
		}
		public bool UpdateShopClass(int ChannelID, int SpecialID, string ClassName, string Tips, string ReadMe, bool ShowOnTop, bool ShowOnIndex, bool IsElite, bool EnableAdd, int ItemListOrderType, int MaxPerPage, int ItemOpenType, string ClassDir, int TemplateID, int ClassSkinID, int ProductTemplateID, string ProductSkinID, int ClassID, bool ChildClassUseSkin, string Attributes_Type, bool HasParameter)
		{
			return Shop_Class.Adapter.UpdateClass(new int?(ChannelID), new int?(SpecialID), ClassName, Tips, ReadMe, new bool?(ShowOnTop), new bool?(ShowOnIndex), new bool?(IsElite), new bool?(EnableAdd), new int?(ItemListOrderType), new int?(MaxPerPage), new int?(ItemOpenType), ClassDir, new int?(TemplateID), new int?(ClassSkinID), new int?(ProductTemplateID), ProductSkinID, new int?(ClassID), new bool?(ChildClassUseSkin), Attributes_Type, new bool?(HasParameter)) >= 1;
		}
		public bool DeleteClassByClassID(int ClassID)
		{
			int num = Shop_Class.Adapter.HLShop_DeleteClass(new int?(ClassID));
			return num == 1;
		}
		public bool InsertClass(int ChannelID, int SpecialID, string ClassName, int ClassType, int OpenType, int ParentID, string Tips, string ReadMe, bool ShowOnTop, bool ShowOnIndex, int ItemListOrderType, bool IsElite, bool EnableAdd, int MaxPerPage, int ItemOpenType, string ClassDir, int TemplateID, int ClassSkinID, int ProductTemplateID, string ProductSkinID, string Attributes_Type, bool HasParameter)
		{
			int num = Shop_Class.Adapter.HLShop_InsertClass(new int?(ChannelID), new int?(SpecialID), ClassName, new int?(ClassType), new int?(OpenType), new int?(ParentID), Tips, ReadMe, new bool?(ShowOnTop), new bool?(ShowOnIndex), new int?(ItemListOrderType), new bool?(IsElite), new bool?(EnableAdd), new int?(MaxPerPage), new int?(ItemOpenType), ClassDir, new int?(TemplateID), new int?(ClassSkinID), new int?(ProductTemplateID), ProductSkinID, Attributes_Type, new bool?(HasParameter));
			return num == 1;
		}
		public DataTable GetSecondClass()
		{
			return Shop_Class.Adapter.GetSecondClass();
		}
		public bool UpdateStatisticProductItemNum(int ClassID, int ItmeNum)
		{
			S_Class.HLShop_ClassDataTable classByClassID = Shop_Class.Adapter.GetClassByClassID(ClassID);
			bool result;
			if (classByClassID.Count == 0)
			{
				result = false;
			}
			else
			{
				S_Class.HLShop_ClassRow hLShop_ClassRow = classByClassID[0];
				hLShop_ClassRow.ItemCount = ItmeNum;
				int num = Shop_Class.Adapter.Update(hLShop_ClassRow);
				result = (num == 1);
			}
			return result;
		}
		public bool UpdateSpecial(int FromSpecialID, int ToSpecialID)
		{
			return Shop_Class.Adapter.UpdateSpecial(new int?(FromSpecialID), new int?(ToSpecialID)) >= 1;
		}
		public void BindTree(int SpecailID, TreeView treeView)
		{
			Shop_Class shop_Class = new Shop_Class();
			treeView.Nodes.Clear();
			DataTable classBySpecialID = Shop_Class.Adapter.GetClassBySpecialID(new int?(SpecailID));
			DataTable allClass = Shop_Class.Adapter.GetAllClass();
			for (int i = 0; i < classBySpecialID.Rows.Count; i++)
			{
				string value = classBySpecialID.Rows[i]["ClassID"].ToString();
				string text = classBySpecialID.Rows[i]["classname"].ToString();
				TreeNode treeNode = new TreeNode();
				treeNode.Text = text;
				treeNode.Value = value;
				treeNode.Expanded = new bool?(true);
				treeView.Nodes.Add(treeNode);
				this.CreateChildNode(treeNode, allClass, SpecailID.ToString());
			}
		}
		public void CreateChildNode(TreeNode parentnode, DataTable dataTable, string SpecailID)
		{
			DataRow[] array = dataTable.Select("ParentID=" + parentnode.Value);
			DataRow[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				DataRow dataRow = array2[i];
				TreeNode treeNode = new TreeNode();
				treeNode.Text = dataRow["ClassName"].ToString();
				treeNode.Value = dataRow["ClassID"].ToString();
				treeNode.Expanded = new bool?(false);
				parentnode.ChildNodes.Add(treeNode);
				this.CreateChildNode(treeNode, dataTable, SpecailID);
			}
		}
		public DataTable GetClassByClassName(string ClassName)
		{
			return Shop_Class.Adapter.GetClassByClassName(ClassName);
		}
		public string GetClassNameByClassID(int ClassID)
		{
			string result;
			if (ClassID > 0)
			{
				DataTable classNameByClassID = Shop_Class.Adapter.GetClassNameByClassID(ClassID);
				if (classNameByClassID.Rows.Count == 1)
				{
					result = classNameByClassID.Rows[0]["ClassName"].ToString();
					return result;
				}
			}
			result = "";
			return result;
		}
		public void SumClassProductNum()
		{
			string sql = "select count(*) As ProductNum, ClassID From HLShop_Product WHERE  IsApprove=1 AND EnableSale=1 And EnableSingleSell=1 AND (EndDate> GetDate() And BeginDate<GetDate()) AND Stocks>0 Group By ClassID";
			this.conn.Execute("update HLShop_Class Set ItemCount=0");
			DataTable dataTable = this.conn.GetDataTable(sql);
			if (dataTable.Rows.Count > 0)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string sql2 = "update HLShop_Class Set ItemCount=" + dataTable.Rows[i][0].ToString() + " where ClassID=" + dataTable.Rows[i][1].ToString();
					this.conn.Execute(sql2);
				}
			}
			DataTable dataTable2 = this.conn.GetDataTable("Select ClassID From HLShop_Class Where Child>0 Order By Depth Desc");
			for (int j = 0; j < dataTable2.Rows.Count; j++)
			{
				string sql3 = "update HLShop_Class Set ItemCount=(Select Sum(ItemCount) From HLShop_Class WHERE ParentID=" + dataTable2.Rows[j][0].ToString() + ") where ClassID=" + dataTable2.Rows[j][0].ToString();
				this.conn.Execute(sql3);
			}
		}
		public void SortRootChildClass(int RootID)
		{
			if (RootID > 0)
			{
				DataTable rootChildClassIDByRootID = Shop_Class.Adapter.GetRootChildClassIDByRootID(new int?(RootID));
				if (rootChildClassIDByRootID != null && rootChildClassIDByRootID.Rows.Count > 0)
				{
					string text = "";
					for (int i = 0; i < rootChildClassIDByRootID.Rows.Count; i++)
					{
						string text2 = text;
						text = string.Concat(new string[]
						{
							text2,
							"Update HLShop_Class Set OrderByID=",
							(i + 1).ToString(),
							" Where ClassID=",
							rootChildClassIDByRootID.Rows[i]["ClassID"].ToString(),
							";",
							Environment.NewLine
						});
					}
					this.conn.ExecuteTransaction(text);
				}
			}
		}
		public void ChangeClassOrder(string ClassID, int ChangeOrder)
		{
			Conn conn = this.conn;
			string sql = "select ClassID,OrderByID,RootID,Child,Depth,arrChildID from hlshop_class where ClassID=" + ClassID;
			DataTable dataTable = conn.GetDataTable(sql);
			string text = "999";
			string[] array = new string[]
			{
				"-",
				"+",
				">=",
				"<"
			};
			if (ChangeOrder < 0)
			{
				array = new string[]
				{
					"+",
					"-",
					"<=",
					">"
				};
			}
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				string text2 = dataTable.Rows[0]["RootID"].ToString();
				string text3 = dataTable.Rows[0]["Depth"].ToString();
				string text4 = dataTable.Rows[0]["arrChildID"].ToString();
				int num = (int)dataTable.Rows[0]["Child"];
				string text5 = "";
				if (text3 == "0")
				{
					int num2 = int.Parse(text2) - ChangeOrder;
					if (num2 < 1)
					{
						num2 = 1;
					}
					if (ChangeOrder > 0)
					{
						int num3 = Convert.ToInt32(conn.GetScalar("select max(RootID) from hlshop_class", new IDbDataParameter[0]));
						if (num2 > num3)
						{
							num2 = int.Parse(text2);
						}
					}
					text5 = " Update HLShop_Class Set RootID =-1 where RootID=" + text2 + ";" + Environment.NewLine;
					object obj = text5;
					text5 = string.Concat(new object[]
					{
						obj,
						" Update HLShop_Class Set RootID =RootID",
						array[1],
						"1 where RootID",
						array[2],
						num2,
						" and RootID",
						array[3],
						text2,
						";",
						Environment.NewLine
					});
					obj = text5;
					text5 = string.Concat(new object[]
					{
						obj,
						" Update HLShop_Class Set RootID=",
						num2,
						" where RootID=-1;",
						Environment.NewLine
					});
				}
				else
				{
					DataTable rootChildClassIDByRootID = Shop_Class.Adapter.GetRootChildClassIDByRootID(new int?(int.Parse(text2)));
					if (rootChildClassIDByRootID != null && rootChildClassIDByRootID.Rows.Count > 0)
					{
						string text6 = "";
						for (int i = 0; i < rootChildClassIDByRootID.Rows.Count; i++)
						{
							string text7 = text6;
							text6 = string.Concat(new string[]
							{
								text7,
								"Update HLShop_Class Set OrderByID=",
								(i + 1).ToString(),
								" Where ClassID=",
								rootChildClassIDByRootID.Rows[i]["ClassID"].ToString(),
								";",
								Environment.NewLine
							});
							if (rootChildClassIDByRootID.Rows[i]["ClassID"].ToString() == ClassID)
							{
								text = (i + 1).ToString();
							}
						}
						conn.ExecuteTransaction(text6);
						string sql2;
						if (ChangeOrder > 0)
						{
							sql2 = string.Concat(new string[]
							{
								"select OrderByID,Child from hlshop_Class where OrderByID<",
								text,
								" and Depth=",
								text3,
								" and RootID=",
								text2,
								" Order By OrderByID desc"
							});
						}
						else
						{
							sql2 = string.Concat(new string[]
							{
								"select OrderByID,Child from hlshop_Class where OrderByID>",
								text,
								" and Depth=",
								text3,
								" and RootID=",
								text2,
								" Order By OrderByID asc"
							});
						}
						DataTable dataTable2 = conn.GetDataTable(sql2);
						int num4 = 0;
						int num5 = 0;
						if (dataTable2 != null && dataTable2.Rows.Count > 0)
						{
							if (ChangeOrder > 0 && ChangeOrder > dataTable2.Rows.Count)
							{
								ChangeOrder = dataTable2.Rows.Count;
							}
							num4 = (int)dataTable2.Rows[Math.Abs(ChangeOrder) - 1]["OrderByID"];
							if (ChangeOrder > 0)
							{
								num5 = int.Parse(text) - num4;
							}
							else
							{
								num5 = num4 - int.Parse(text) - num;
							}
						}
						text5 = string.Concat(new object[]
						{
							" Update HLShop_Class Set OrderByID=OrderByID",
							array[0],
							num5,
							" where ClassID in(",
							text4,
							");",
							Environment.NewLine
						});
						object obj = text5;
						text5 = string.Concat(new object[]
						{
							obj,
							" Update HLShop_Class Set OrderByID=OrderByID",
							array[1],
							num + 1,
							" where (OrderByID ",
							array[2],
							num4,
							" and OrderByID ",
							array[3],
							text,
							") and RootID=",
							text2,
							" and ClassID not in(",
							text4,
							");"
						});
					}
				}
				conn.ExecuteTransaction(text5);
			}
		}
		public void RepairClass()
		{
			string sql = "select ClassID from HLSHop_Class Where Depth=0 Order By RootID asc";
			Conn conn = this.conn;
			DataTable dataTable = conn.GetDataTable(sql);
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				int num = i + 1;
				this.GetChildID(dataTable.Rows[i]["ClassID"].ToString(), 0, "", "0", 0, num.ToString());
			}
			conn.ExecuteTransaction(this.m_UpdateSql);
		}
		public void RepairClass(string ClassID)
		{
			string sql = "select ParentID,Depth,arrChildID,ParentPath,Child,RootID from HLSHop_Class Where ClassID=" + ClassID;
			Conn conn = this.conn;
			DataTable dataTable = conn.GetDataTable(sql);
			if (dataTable != null && dataTable.Rows.Count == 1)
			{
				DataRow dataRow = dataTable.Rows[0];
				this.GetChildID(ClassID, (int)dataRow["Depth"], "", dataRow["parentPath"].ToString(), (int)dataRow["Child"], dataRow["RootID"].ToString());
				conn.ExecuteTransaction(this.m_UpdateSql);
			}
		}
		public void RepairClass(string RootClassID, string RootID)
		{
			Conn conn = this.conn;
			this.GetChildID(RootClassID, 0, "", "0", 0, RootID);
			conn.ExecuteTransaction(this.m_UpdateSql);
		}
		public void RepairClass(string ClassID, string RootID, bool FromRootRepair)
		{
			Conn conn = this.conn;
			if (FromRootRepair)
			{
				string sql = "select ClassID from HLSHop_Class Where Depth=0 and RootID=" + RootID;
				DataTable dataTable = conn.GetDataTable(sql);
				if (dataTable != null && dataTable.Rows.Count == 1)
				{
					ClassID = dataTable.Rows[0]["ClassID"].ToString();
					this.RepairClass(ClassID, RootID);
				}
			}
			else
			{
				this.RepairClass(ClassID);
			}
		}
		protected string GetChildID(string ParentID, int Depth, string ParentChildArray, string ParentPath, int ChildNums, string RootID)
		{
			Conn conn = this.conn;
			DataTable dataTable = conn.GetDataTable("select ClassID from hlshop_class where parentID =" + ParentID);
			int num = 0;
			string text = "";
			string result;
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				string text2 = "";
				int num2 = 0;
				string parentPath = ParentPath + "," + ParentID;
				foreach (DataRow dataRow in dataTable.Rows)
				{
					num2++;
					text2 = text2 + dataRow[0].ToString() + ",";
				}
				ChildNums += num2;
				text2 = text2.Remove(text2.Length - 1);
				ParentChildArray += text2;
				string[] array = text2.Split(new char[]
				{
					','
				});
				string[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					string parentID = array2[i];
					string childID = this.GetChildID(parentID, Depth + 1, ParentChildArray, parentPath, ChildNums, RootID);
					if (!text.Contains(childID))
					{
						text = text + childID + ",";
					}
				}
				text = ParentID + "," + text.Remove(text.Length - 1);
				string[] array3 = text.Split(new char[]
				{
					','
				});
				num = array3.Length - 1;
				result = text;
			}
			else
			{
				text = ParentID;
				result = ParentID.ToString();
			}
			object updateSql = this.m_UpdateSql;
			this.m_UpdateSql = string.Concat(new object[]
			{
				updateSql,
				"update hlshop_class set Depth=",
				Depth,
				",ParentPath='",
				ParentPath,
				"',Child=",
				num.ToString(),
				",arrChildID='",
				text,
				"',RootID=",
				RootID,
				"  where ClassID=",
				ParentID,
				";",
				Environment.NewLine
			});
			return result;
		}
		public void BindDropDownListClassMapPath(DropDownList ddl)
		{
			this.BindDropDownListClassMapPath(ddl, "");
		}
		public void BindDropDownListClassMapPath(DropDownList ddl, string SelectClassID)
		{
			Shop_Class shop_Class = new Shop_Class();
			DataTable allClass = shop_Class.GetAllClass();
			this.BindDropDownListClassMapPath(ddl, allClass, SelectClassID);
		}
		public void BindDropDownListClassMapPath(DropDownList ddl, DataTable dt)
		{
			this.BindDropDownListClassMapPath(ddl, dt, "");
		}
		public void BindDropDownListClassMapPath(DropDownList ddl, DataTable dt, string SelectClassID)
		{
			if (dt != null && dt.Rows.Count > 0)
			{
				foreach (DataRow dataRow in dt.Rows)
				{
					ListItem item = new ListItem(this.ShowClassPath(dataRow["ClassName"].ToString(), (int)dataRow["Depth"]), dataRow["ClassID"].ToString());
					ddl.Items.Add(item);
					if (SelectClassID != "" && dataRow["ClassID"].ToString() == SelectClassID)
					{
						ddl.SelectedValue = SelectClassID;
					}
				}
			}
		}
		protected string ShowClassPath(string ClassName, int Depth)
		{
			string str = "";
			for (int i = 1; i < Depth; i++)
			{
				str += "--";
			}
			if (Depth > 0)
			{
				str += "└";
			}
			return str + ClassName;
		}
		public string GetChildClassids(int pClassid)
		{
			string result;
			if (pClassid > 0)
			{
				string text = (string)this.conn.GetScalar(string.Format("select dbo.GetChildrenClassIDByParentID({0})", pClassid), new IDbDataParameter[0]);
				result = text;
			}
			else
			{
				result = "0";
			}
			return result;
		}
	}
}
